import psycopg2

class DatabaseOperations:
    def __init__(self, host, dbname, user, password, port):
        self.conn = psycopg2.connect(
            dbname=dbname,
            user=user,
            password=password,
            host=host,
            port=port
        )
        self.cur = self.conn.cursor()
    
    def execute_query(self, query, params=None):
        self.cur.execute(query, params)
        self.conn.commit()
    
    def fetch_query(self, query, params=None):
        self.cur.execute(query, params)
        return self.cur.fetchall()
    
    def close(self):
        self.cur.close()
        self.conn.close()
